home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
bathints.zip
/
BH_03.DOC
< prev
next >
Wrap
Text File
|
1987-10-26
|
2KB
|
57 lines
BAT-HINT # 3
**************************************************************************
from the BATHINTS library... part of the BATPOWER CONFERENCE from:
THE PAINFRAME OPUS/FIDO 261/1004
Baltimore, Maryland 1-301-488-7461
**************************************************************************
The FOR command:
Placing executable files in SET
The FOR command has the following syntax:
FOR %%V IN (SET) DO command
While SET usually involves filenames with or without the global charcters
(? and *), SET may include any executable file (i.e. .exe .com .bat) or any
of the DOS internal commands. Note the example shown below:
SAMPLE.BAT
echo off
FOR %%V IN (*.doc) DO copy %%V c:\document
The batch file above will copy each *.doc file in the current drive and
directory to c:\document. This batch file can be improved however, by
a little creative rearrangement:
BETTER.BAT
echo off
FOR %%V IN (copy) DO %%V *.doc c:\document
What is the difference between sample.bat and better.bat? Sample.bat copies
each *.doc file to c:\document one at a time, whereas better.bat copies the
*.doc files to c:\document as if entered at the command line as:
copy *.doc c:\document
Try it and see. Several public domain programs are available that copy and
then erase files from source and destination directories (i.e. move.com),
effectively moving the files from one subdirectory to another. The same
function can be performed by the following command line placed in a batch
file:
FOR %%V IN (copy del) DO %%V *.* c:\otherdir
This batch file command line will copy all files in the current drive and
directory to c:\otherdir then delete the files from the current drive and
directory... essentially a "move" command.
******************************************************** David Creasey